import request from "@/utils/request"

export enum EmployeeStatus {
  启用 = 1,
  禁用 = 2,
}

export interface QueryEmployeeListParams extends PaginationParams {
  username?: string
  telephone?: string
  status?: EmployeeStatus
}

export interface Employee {
  createTime: number
  id: number
  status: EmployeeStatus
  telephone: string
  username: string
  roles?: string[]
  roleVos?: Role[]
}

export async function queryEmployeeList(params: QueryEmployeeListParams) {
  return request<Employee[]>('/app/manager/user/list', {
    data: params,
  })
}

export async function editEmployee(params: Employee) {
  return request('/app/manager/user/addOrUp', {
    data: params,
  })
}

export async function getEmployeeInfo(params: {userId: number}) {
  return request<Employee>('/app/manager/user/detail', {
    data: params,
  })
}

export async function delEmployee(params: {
  id: number, 
  status: 1 | 2 | 3, // 1:启用，2-禁用，3-删除
}) {
  return request('/app/manager/user/del', {
    data: params,
  })
}

export async function passRest(params: {id: number}) {
  return request('/app/manager/user/passRest', {
    data: params,
  })
}
